#include<stdio.h>
#include <stdlib.h>
#include"tcp.h"
#include"session.h"

//./ftpClient 服务端ip 服务端端口号
int main(int argc,char *argv[])
{
	int sockfd = connect_server(argv[1],atoi(argv[2]));
	if(sockfd == -1)
	{
		return -1;
	}
	
	int cmd;
	int shutdown=0;
	while(1)
	{
		printf("请输入您的操作:\n");
		printf("---------0,退出操作\n");
		printf("---------1,ls操作\n");
		printf("---------2,upload操作\n");
		printf("---------3,download操作\n");
		scanf("%d",&cmd);
		getchar();
		switch(cmd)
		{
			case 0:
				//写退出相关的代码
				shutdown=Closecmd(sockfd);
				if(shutdown==-1)
				{
					return 0;
				}
				break;
			case 1:
				//写ls相关的代码
				lsCmd(sockfd);
				break;
			case 2:
				//写上传相关的代码				
				printf("请输入要上传的文件名:");
				char Uploadfilename[100];
				scanf("%s",Uploadfilename);
				printf("%s\n",Uploadfilename);
				uploadFile(sockfd,Uploadfilename);				
				break;
			case 3:
				//写下载相关的代码
				printf("请输入要下载的文件名:");
				char Downloadfilename[100];
				scanf("%s",Downloadfilename);
				printf("%s\n",Downloadfilename);
				downloadFile(sockfd,Downloadfilename);
				break;
		}
		
	}
	printf("客服务到底有没有gg啊\n");
}